package com.zixi.beverage_order.controller.customer;

import com.zixi.beverage_order.pojo.OrderList;
import com.zixi.beverage_order.pojo.OrderedProduct;
import com.zixi.beverage_order.pojo.Product;
import com.zixi.beverage_order.pojo.ReturnOrderedProduct;
import com.zixi.beverage_order.service.customer.WxOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/order")
@ResponseBody
public class WxOrderController {
//    用户未确认订单前选择订单的控制类

    @Autowired
    WxOrderService wxOrderService;
    @GetMapping("/allproduct")
    //拿到所有的产品显示
    public List<Product> getAllProduct(){
        System.out.println("进入了Controller");
        return wxOrderService.getAllProduct();
    }

    @PostMapping("/orderedproduct")
    //点单一款产品
    public Object getOrderedProduct(@RequestBody OrderedProduct orderedProduct){
        return wxOrderService.getOrderedProduct(orderedProduct);
    }

    @PostMapping("/updateOrderedProduct")
    //修改在购物车的商品
    public ReturnOrderedProduct updateOrderedProduct(@RequestBody OrderedProduct orderedProduct){
        System.out.println("我到这了！！！！！"+orderedProduct);
        return wxOrderService.updateOrderedProduct(orderedProduct);
    }

    @PostMapping("/buythese")
    //将购物车的订单购买，并基于购买时间
    public Object buyThese(@RequestBody OrderList orderList){
        return wxOrderService.buyThese(orderList);
    }

    @PostMapping("/deleteit")
    public Object deleteIt(@RequestBody OrderedProduct orderedProduct){
        wxOrderService.deleteIt(orderedProduct);
        return null;
    }
}
